﻿using System;
using System.Web.UI;
using Wei8808Cms.BLL;
using Wei8808Cms.Model;
using Wei8808Cms.Utility;
using Wei8808Cms.WebSite.UI;

namespace Wei8808Cms.WebSite.admin.Adbanner
{
    public partial class AddAdbannerInfoForm : BasicPage
    {
        private readonly AdbannerBLL _bll = new AdbannerBLL();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Page.IsPostBack) return;
            chkLoginLevel("AddAdbanner");
        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                var model = new AdbannerInfo
                {
                    Id = GuidHelper.GetGuid(),
                    Title = txtTitle.Text.Trim(),
                    ImgUrl = txtImgUrl.Text.Trim(),
                    LinkUrl = txtLinkUrl.Text.Trim(),
                    TopRemark = txtTopRemark.Text.Trim(),
                    BottomRemark = txtBottomRemark.Text.Trim(),
                    IsLock = 0
                };
                if (rblIsLock.Items[0].Selected == true)
                {
                    model.IsLock = 0;
                }
                if (rblIsLock.Items[1].Selected == true)
                {
                    model.IsLock = 1;
                }
                model.CreateUser = "李波";
                model.CreateTime = DateTime.Now;
                _bll.Add(model);
                JscriptPrint("增加成功！", "AddAdbannerInfoForm.aspx", "Success");
            }
            catch (Exception ex)
            {
                JscriptPrint("异常：" + ex.Message, "AdbannerMasterForm.aspx", "Error");
            }
        }
    }
}